package com.frontier.gateway8000.filter.keyresolver;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


/**
 * 自定义RequestRateLimiterGatewayFilterFactory限流规则
 *
 * @author YLS-XuXu
 * @date 2022/3/3
 */
@Component
public class UrlKeyResolver implements KeyResolver {

    /**
     * 自定义URL限流规则
     *
     * @param exchange
     * @return reactor.core.publisher.Mono<java.lang.String>
     */
    public Mono<String> resolve(ServerWebExchange exchange) {
        return Mono.just(exchange.getRequest().getURI().getPath());
    }
}